\gray
\section{Schemes}
\subsection{Sheaves}
\begin{definition}[Presheaf]\label{Presheaf}
Let $(X,\tau)$ be a topological space. A presheaf $\bcF$ of $\bcC$ on $(X,\tau)$ is a contravariant functor from the pre-ordered category $\bcO(\tau)$ to the category $\bcC$. Where $\bcO(\tau)$ is the pre-ordered category whose object are the open sets in $(X,\tau)$.
\end{definition}
\begin{remark}
A presheaf $\bcF$ of $\bcC$ on $(X,\tau)$ assigns to each open set $U\subseteq X$ an object of $\bcC$, and for the unique morphism $\bcO(\tau)$ induced by the inclusion $V\subseteq U$ a morphism $\rho_{UV}:\bcF(U)\rightarrow \bcF(V)$ in $\bcC$, such that the below hold:
\begin{itemize}

\item $\rho_{UU}=Id_{\bcF(U)}$.
\item $W\subseteq V\subseteq U\Rightarrow \rho_{UW}=\rho_{VW}\circ \rho_{UV}$.
\item $\bcF(\emptyset)=\mathfrak{0}$. \tcb{Why to add this condition?}. For any set $Y,\exists!f:\emptyset\rightarrow Y$, so if $\bcF(\emptyset)$ is a set of function then it has a unique function and it forms the zero group, ring,...\\
Moreover, that the last condition is not guaranteed by the definition \ref{Presheaf}. That, having $\bcF$ a contravariant functor, and $\emptyset$ an initial object in $\bcO(\tau)$, implies that $\bcF(\emptyset)$ is a terminal object of the subcategory of $\bcC$ on which $\bcF$ is full. However, in general the terminals of $\bcC$ does not have to be the image of any object of $\bcO(\tau)$.
\end{itemize}
\end{remark}
\begin{question}
Why do we restrict the definition to open subsets, i.e. elements of some topology rather than considering different classes of subsets? Is it because the constructed objects are well-defined if working on open sets. And that they will differ based on the considered topology, otherwise one could have just work only with the discrete topology.

\tcb{Did we require the presheaf to map the empty set to zero, because otherwise the sheafification of a sheaf wont be isomorphic to the original sheaf? }
\end{question}
\begin{terminology}
\begin{itemize}

\item For the presheaf $\bcF$ on $(X,\tau)$. If $\bcF{U}$ is a set equipped with some structure, we call $s\in \bcF(U)$ a section on $U$. \tcb{Did the name come from algebraic geometry, or is there a deeper concept behind the name?}
\item We denote $\bcF(U)$ by $\Gamma(U,\bcF)$. \tcb{What does it mean in cohomology?}
\item We call $\rho_{UV}$ a restriction map, and we denote $s|_V:=\rho_{UV}(s)\in \bcF(V),s\in\bcF(U)$.
\end{itemize}
\end{terminology}
\begin{definition}[Sheaf on concrete category]\tcb{Define it in general}\\
We call the presheaf $\bcF$ of $\bcC$ on $X$ a sheaf iff the following axioms are satisfied:
\begin{itemize}

\item (Local identity)\label{LI} For an open cover $\{U_i:i\in I\}$ of $U\in \tau$, if $s,t\in\bcF(U)$ such that $s|_{U_i}=t|_{U_i},i\in I$, then $s=t$.
\item (Gluing) For an open cover $\{U_i:i\in I\}$ of $U\in \tau$, if $s_i\in\bcF(U_i)$ such that $s_i|_{U_i\bigcap U_j}=s_j|_{U_i\bigcap U_j},\forall i,j\in I$, then $\exists s\in \bcF(U)$ such that $s|_{U_i}=s_i,\forall i\in I$.
\end{itemize}
\end{definition}
Such $s$ is unique as per the first condition.
\begin{terminology}
We call such $s$, the gluing of $s_i$'s.
\end{terminology}
Would the first condition be redundant if we require $s$ to be unique? i.e. is the first condition used for anything rather than guaranteeing that the uniqueness of such $s$ in the above def,if not, delete first condition and add the uniqueness to the second condition.\\
It does not guarantee that that $\rho_{UU_i}$ are injections, that the condition is not taken for each one alone. 
\begin{counterexample}
\tcb{give example of sheaf/presheaf, where $\bcC$ is not a concrete category, and more specificity where $\bcF(U)$ are not sets}.
\end{counterexample}
\begin{definition}[Locally-defined property.]
Let $R$ be a property defined on the open subsets $U\subseteq X$, such that $R(U)$ is satisfied iff $R(U_i)$ is satisfied for an open cover $\{U_i:i\in I\}$ of $U$, then we say that $R$ a locally-defined property.
\end{definition}
\begin{lemma}
Let $\bcF$ be a presheaf of $\bcC$ on $X$, such that $\bcC$ is concrete, and for every open subset $U\subseteq X$, $\bcF(U)$ is a set of functions on $U$ with locally-defined property. Then, $\bcF$ is a sheaf.
\end{lemma}
\begin{proof}
\tcb{prove it}
\end{proof}
\begin{example}[Examples of sheaves]
\begin{itemize}

\item The sheaf of regular functions $\bcO(X)$ on a \tcb{variety} $X$.
\item The sheaf of continuous real-valued functions on a topological space.
\item The sheaf of differentiable complex-valued functions on a differentiable manifold.
\item \tcb{other examples} try to take the min of Spec of prime ideals! it should work.
\end{itemize}
\end{example}
\begin{example}[The constant sheaf]
Let $(X,\tau)$ be a topological space, $(G,\tau')$ the discrete topological space on a an abelian group $G$. Then, we may define $\bcF(U)$ to be the set of continuous functions from $U$ to $G$ with respect to the topologies $\tau|_U$ (inherited topology) and $\tau'$, respectively. and let $\rho_{UV}$ be the canonical restriction, where $V\subseteq U$. Then, we find that $\bcF$ defines an sheaf of abelian group on $X$.
\begin{proof}
For every $U\in \tau$, then $\exists \underline{e}:U\rightarrow G$, given by $\underline{e}(x)=e$, where $e$ is the identity of the group $G$. $\underline{e}$ is continuous with respect to $\tau|_{U}$ and $\tau'$. hence, $\underline{e}\in \bcF(U)\neq\emptyset$. Also, we find that $\bcF(U)$ is an abelian group with respect to point-wise defined multiplication, induced from the multiplication of $G$.\\
\tcb{finish the proof to find that it defines a sheaf}.\\
One can readily check that, if $\{U_i, i=1..n\}$ is the \underline{open} connected components of $U$ , then $\bcF(U)\cong \otimes_{i=1}^n G$.
\end{proof}
\end{example}
\begin{question}
How can one use the notion of sheaves?
\end{question}
We notice that a presheaf, in the above setting, is an object of the category $\bcC^{\bcO(\tau)^{op}}$. Then, it would be natural to define a morphisms of presheaves on $(X,\tau)$ as morphism in $\bcC^{\bcO(\tau)^{op}}$, i.e. a natural transformation. And we define the isomorphisms of presheaves on $(X,\tau)$ as natural isomorphism.
\begin{definition}
We define the category of presheaves of $\bcC$ on $(X,\tau)$ to be $\bcC^{\bcO(\tau)^{op}}$, denoted $\mathfrak{PreShf}(\bcC,(X,\tau))$, and we define the category of sheaves of $\bcC$ on $(X,\tau)$ to be full subcategory of $\bcC^{\bcO(\tau)^{op}}$, whose object are sheaves, denoted $\mathfrak{Shf}(\bcC,(X,\tau))$.
\end{definition}
\begin{remark}
One can then consider endofunctors on $\bcC^{\bcO(\tau)^{op}}$, and study if the subcategory of sheaves is invariant under them. We will see some examples, where subcategory of sheaves is not invariant under endofunctors on $\bcC^{\bcO(\tau)^{op}}$. Then, one might try check if either the right or left adjunction of the inclusion functor $\goi:\mathfrak{Shf}(\bcC,(X,\tau))\rightarrow\mathfrak{PreShf}(\bcC,(X,\tau))$ exist, and use this adjunction to associate a sheaf for each presheaf.
\end{remark}
For any presheaves $\bcF,\bcG$ on $(X,\tau)$, and a morphism of presheaves, then $\varphi(U):\bcF(U)\rightarrow\bcG(U)$ is a morphism in $\bcC$. Then, if then if $\bcC$ has zero, and $\ker$ for its arrows, then we can define \[\underline{\ker}(U)=\ker(\varphi(U)):k(U)\rightarrow \bcF(U)\]
We notice that for $V\subseteq U \in \tau$ that the following diagram commute:
\[
\xymatrix{
k(U)\ar[rr]^{\ker(\varphi(U))}&&\bcF(U)\ar[rr]^{\varphi(U)}\ar[d]_{\rho_{UV}}&&\bcG(U)\ar[d]^{\rho'_{UV}}\\
k(V)\ar[rr]_{\ker(\varphi(V))}&&\bcF(V)\ar[rr]_{\varphi(V)}&&\bcG(V)
}
\]
Where $\rho_{UV}$, $\rho'_{UV}$ are the restriction of $\bcF,\bcG$, respectively.
Notice that $0_{k(U)\bcG(V)}=\rho'_{UV}0_{k(U)\bcG(U)}\\=\rho'_{UV}\varphi(U)\ker(\varphi(U))=\varphi(V)\rho_{UV}\ker(\varphi(U))$\\
The universal property of the kernel implies the existence of a unique arrow $\rho^{\ker}_{UV}:
\rho_{UV}\ker(\varphi(U))\stackrel{\cdot}{\rightarrow} \ker(\varphi(V))$ that makes the following diagram commutative:
\[
\xymatrix{
k(U)\ar[rr]^{\ker(\varphi(U))}\ar@{-->}[d]_{\rho^{\ker}_{UV}}&&\bcF(U)\ar[rr]^{\varphi(U)}\ar[d]_{\rho_{UV}}&&\bcG(U)\ar[d]^{\rho'_{UV}}\\
k(V)\ar[rr]_{\ker(\varphi(V))}&&\bcF(V)\ar[rr]_{\varphi(V)}&&\bcG(V)
}
\]
Now, we see that $\ker(\varphi(U))\in \bcC^{^{\cdot\rightarrow\cdot}}$ and that $(\rho^{\ker}_{UV},\rho_{UV}),(\rho^{\ker}_{UV},\rho'_{UV})$ in $\bcC^{^{\cdot\rightarrow\cdot}}$. Then, based on having $\bcF,\bcG\in \bcC^{\bcO(\tau)^{op}}$, and the universal property of $\ker$, one finds that $\mathfrak{ker}(\varphi):\bcO(\tau)\rightarrow \bcC^{^{\cdot\rightarrow\cdot}}$ is a contravariant functor for:
$\mathfrak{ker}(\varphi)(U)=\ker(\varphi(U)), \mathfrak{ker}(\varphi)(V\subseteq U)=(\rho^{\ker}_{UV},\rho_{UV})$. Hence, $\mathfrak{ker}(\varphi)$ is a presheaf of $\bcC^{^{\cdot\rightarrow\cdot}}$ on $(X,\tau)$, where $V\subseteq U$ denotes the unique morphism $U\rightarrow V$ in $\bcO(\tau)$.\\
It can also be thought of as a a presheaf of $\bcC$ on $(X,\tau)$ when we alter the definition of $\mathfrak{ker}$, as follows:
$\mathfrak{ker}(\varphi)(U)=k(U), \mathfrak{ker}(\varphi)(V\subseteq U)=\rho^{\ker}_{UV}$, as per the above setting. The same argument applies for $\coker, \im, \coim$.\\

We notice that $\mathfrak{ker}(\varphi)$ is a sheaf. However, $\mathfrak{coker}(\varphi),\mathfrak{im}(\varphi)$, they do not necessary define a sheaf, when defined. \tcb{What about $\coim$?}

Now, one might consider associating a sheaf for every presheaf in natural way such that the sheaf associated to a sheaf must be isomorphic to the original one.

\tcb{Show how this process leads to the definition of stalks.}

\begin{remark}
Let $\bcF$ be a presheaf of $\bcC$ on $(X,\tau)$. For each $x\in X$, let $O(\tau,x)$ be the set of open subsets in $X$ that contains $x$. It is partially order set with respect to $\subseteq$. Then, $(O(\tau,x), \leq)$ is filtered set, where the relation $leq$ is defined by $U\leq V \Leftrightarrow V\subseteq U$. 
Then, $\{(\bcF(U),\rho_{UV}):U,V\in O(\tau,x)\}$ is a directed system. Then, a natural question arise, does the direct and inverse limit (colimmit and limit) of this system exists in $\bcC$.
\end{remark}
\begin{remark}
Alternatively, one might consider the preordered category $J:=(\bcO(\tau,x))^{op}$, and then check if the direct and inverse limit of $\bcF$ exists in $\bcC$.
\end{remark}

The above question are settled in specific cases, for example when $\bcC=\mathfrak{Ab},\mathfrak{Rng},...$, as we will see below \tcb{check it in general}.
\begin{question}
Give an example of a presheaf where the direct limit does not exist. Or is it that limit always exists because J is filtered, or partially ordered.\\
\end{question}
\begin{definition}[Stalk]
Let $\bcF$ be a presheaf of $\bcC$ on $(X,\tau)$, such that $\bcC$ has all clolimits, we define the stalk of $x\in X$ to be $\underrightarrow{\lim}\bcG$, where $\bcG:\bcO(X,x)\rightarrow \bcC$ is the induced functor from $\bcF$. We denote the stalk of $x$ by $\bcF_x$.
\end{definition}
\begin{example}
Since the category $\mathfrak{Grp}$ has its colimits \cite[P 209]{Maclane98}, then $\bcF_x$ is defined for presheaves of groups on $(X,\tau)$.
\end{example}
\begin{lemma}\label{InducedMor}
Let $\bcC$ be concrete category that has all clolimits, and $\bcF,\bcG$ presheaves of $\bcC$ on $(X,\tau)$. then a morphism of presheaves $\varphi:\bcF\rightarrow \bcG$  induce a morphism $\varphi_x:\bcF_x\rightarrow \bcG_x$ in $\bcC$, for all $x\in X$. Moreover, if $\varphi$ is an isomorphism, then $\varphi_x$ are so, for all $x\in X$, the convers is not true in general, unless $\bcF,\bcG$ are sheaves \tcb{(would one of them be enough?)}.
\end{lemma}
\begin{proof}
Based on the definition of colimit and presheaves morphisms, we find that the below diagram commutes:
\[
\xymatrix{
\bcF(U)\ar[dd]^{\varphi(U)}\ar[r]\ar[rrd]_{\mu_U}&\bcF(V)\ar[dd]^{\varphi(V)}\ar@{..>}[rr]\ar[rd]^{\mu_V}&&...\ar[dd]^{\varphi(...)}&&\bcF(W)\ar@{..>}[ll]\ar[llld]^{\mu_W}\ar[dd]^{\varphi(W)}\\
&&\bcF_x&&&\\
\bcG(U)\ar[r]\ar[rrd]_{\nu_U}&\bcG(V)\ar@{..>}[rr]\ar[rd]^{\nu_V}&&...&&\bcG(W)\ar@{..>}[ll]\ar[llld]^{\nu_W}\\
&&\bcG_x&&&
}
\]
\end{proof}
Then we will have the cone to $\bcG_x$ with a diagram $\bcF(U)\rightarrow\bcF(V)\rightarrow...\leftarrow\bcF(W)$, which implies that there exist a unique morphism $\varphi:\bcF_x\rightarrow \bcG_x$ that makes the above diagram commute.

If $\varphi$ is an isomorphism,..\tcb{finish typing the proof}.

\begin{theorem}\label{AdjShf}
Let $\bcC$ be concrete category that has all clolimits, then there is a left/right adjunction for the inclusion functor $\mathfrak{i}:\mathfrak{Shf}\rightarrow\mathfrak{PreShf}$
\end{theorem}
\begin{proof}

\end{proof}
\begin{question}
Once we have an adjunction, we have a (co)monad structure and one might investigate (co)algebras of this (co)monad.
\end{question}
extend 
subshef
\begin{theorem}\label{StalksIso}
isomorphi
\end{theorem}
\begin{proposition}\label{MSh}
Morphism of sheafs of on diff topological spaces
\end{proposition}

last page.
Give an example of none-trivial stalk, where $\bcF(U)$ are not sets.

\subsection{Schemes}
\label{Scheme}

\subsubsection{Affine Scheme}
\begin{definition}[Prime Spectrum]
Let $R$ be a ring, we define the prime spectrum of $R$ to be the set of prime ideals of $R$, denoted by $\Spec R$.
For any subset $S\subseteq A$ we define $\VV(S):=\{\gop\in \Spec R:S\subseteq \gop\}$.
\end{definition}

\begin{remark}
We could have defined it for any set, but the unique representation of an ideal as an intersection of prime ideals make it sufficient and more efficient to require $I$ to be an ideal, actually we could have only used radical ideals as \ref{Rad} indicate.
\end{remark}
\begin{lemma}\label{SpecTop}
The set $\tau:=\{\Spec\setminus\VV(a): a\subseteq A \text{ is an ideal} \}$ defines a topology on $\Spec A$
\end{lemma}
\begin{proof}
Note that $\Spec A,\emptyset\in \tau$ because $\Spec A=\VV(\{0\}),\emptyset=\VV(A)$.\\
Let $a,b\subseteq A$ be ideals of $A$, then $\VV(a)\bigcup \VV(b)=\VV(ab)$, that:\\
$\forall \gop\in \VV(a)\bigcup \VV(b)\Leftrightarrow$ either $a\subseteq \gop$ or $b\subseteq \gop$ $\Leftrightarrow ab\subseteq \gop\Leftrightarrow\gop\in \VV(ab)$. Therefore, $\tau$ is closed under finite intersections.\\
Let $\{a_i,  i\in I \}$ be a family of ideals of $A$, then $\displaystyle\bigcap_{i\in I}\VV(a_i)=\VV(\displaystyle\sum_{i\in I}a_i)$, that:\\
$\forall \gop\in \displaystyle\bigcap_{i\in I}\VV(a_i) \Leftrightarrow a_i\subseteq \gop, \forall i\in I\Leftrightarrow \displaystyle\sum_{i\in I}a_i\subseteq \gop  \Leftrightarrow \gop\in \VV(\displaystyle\sum_{i\in I}a_i)$. Therefore, $\tau$ is closed under arbitrary union.\\
\end{proof}
\begin{lemma}\label{Rad}
let $a,b$ be ideals in $A$, then $\VV(a)\subseteq \VV(b)$ iff $\Rad(b)\subseteq \Rad(a)$.
\end{lemma}
\begin{definition}	
Let $D(f)$ denotes the open complement of $\VV((f))$ in $(\Spec A,\tau), \forall f\in A$.
\end{definition}
\begin{lemma}
Open sets of the form $D(f), f\in A$ defines a basis for the topological space $(\Spec A,\tau)$.
\end{lemma}
\begin{proof}
What will show is actually that each open set of $(\Spec A,\tau)$ is of the form $D(f), f\in A$. That, let $U\in \tau\Rightarrow U=\Spec A\setminus\VV(a)$, for some ideal $a$. Let $\gop\in U\Rightarrow\gop\notin \VV(a)\Rightarrow a\nsubseteq \gop$, so there is $f\in a, f\notin \gop\Rightarrow (f)\nsubseteq \gop\Rightarrow \gop\notin \VV((f))\Rightarrow \gop\in D(f)\Rightarrow U\subseteq D(f)$.\\
Let $\gop\in D(f)\bigcap \VV(a)\Rightarrow (f)\nsubseteq \gop, a\subseteq \gop$, which contradict with having $f\in a$. Hence, $D(f)\bigcap \VV(a)=\emptyset$, i.e. $U=D(f)$.
\end{proof}
The above lema implies that we could have defined the same topology using principal ideal generated by \tcb{irreducible/prime} elements.


Having constructed the topological space $(\Spec A,\tau)$, we can define a sheaf of ring on it, by defining the stalks of this sheaf. That, \ref{StalksIso} shows that sheaves are fully determine by their stalks. Otherwise, we can define a presheaf of rings on $(\Spec A,\tau)$ and find its sheafification.\\
\begin{definition}
For every $U\in \tau$, define $\bcO'(U)=\displaystyle\bigcap_{\gop\in U}A_{\gop}$. Then, for $V\subseteq U\in \tau$, we have $\bcO'(U)\subseteq \bcO'(V)$, and we define $\rho_{UV}:\bcO'(U)\rightarrow \bcO'(V)$ to be the canonical inclusion.
\end{definition}
\begin{lemma}
The above defined $\bcO'$ is a presheaf of rings on $(\Spec A,\tau)$, and its stalks are $\bcO'_{\gop}\cong A_{\gop},\forall \gop\in \Spec A$.
\end{lemma}
\begin{proof}
It does not hold at $\emptyset$, but should not be an issue as the sheafification takes care of it.\\
\tcb{or maybe we need to define it using the complement}.
\end{proof}
\begin{question}
Show why $\bcO'$ is not a sheaf itself! give an example.
\end{question}
Then, by Theorem \ref{AdjShf}, there is a sheaf $\bcO'^+$ of rings of functions on $(\Spec A,\tau)$, and its stalks are $\bcO'^+_{\gop}=A_{\gop}$. So, what is written in \cite[P 70]{Har77} is nothing but the result the this sheafification.\\
From now on, we will denote $\bcO:=\bcO'^+$
\begin{definition}
Let $A$ be a ring, then the spectrum of $A$ is the pair $((\Spec A,\tau),\bcO)$, as in the above settings.
\end{definition}
\tcb{Prove that the below definition is equivalent to the the one above.}

\begin{lemma}
Let $A$ be a ring, and $((\Spec A,\tau),\bcO)$ its spectrum, then for $U\in \tau,\bcO(U)$ is the ring of functions $s:U\rightarrow \displaystyle\bigsqcup_{\gop\in U}A_{\gop}$ such that $s(\gop)\in A_{\gop}$, and $\forall \gop\in U,\exists V\in tau, \gop\in V\subseteq U$ such that $\exists a,f\in A,\forall \goq\in V, f\notin \goq$ and $s(q)=a/f\in A_{\goq}$. And the restriction function are the canonical restrictions on set of functions.
\end{lemma}
\begin{proof}
It is just the description of sheafification.
\end{proof}
\begin{proposition}
Let $A$ be a ring, and $((\Spec A,\tau),\bcO)$ its spectrum, then:
\begin{enumerate}
\item \label{a} $\forall \gop\in \Spec A, \bcO_{\gop}\cong A_{\gop}$.
\item \label{b} $\forall f\in A, \bcO(D(f))\cong A_f$.
\item \label{c} $\Gamma(\Spec A,\bcO)\cong A$. \tcb{quite useful!}
\end{enumerate}
\end{proposition}
\begin{proof} The first condition is true due to the sheafification. However, if one adopted the above lemma as a definition of the sheaf of the spectrum, the one can follow the following argument.
\begin{enumerate}
\item \tcb{rewite it}\\
$\forall \gop\in \Spec A,\\ \forall s_{\gop}\in \bcO_{\gop}, \exists V_{\gop}\in \tau,\gop\in V_{\gop}
: \exists a,f\in A:\  \forall \goq \in V_{\gop}, f\notin \goq$ and $s_{\gop}(\goq)=a/f$.
Since $\forall \goq \in V_{\gop}, f\notin \goq, \gop\in V_{\gop}$, then $f\notin \gop$, i.e. $f^{-1}\in A_{\gop}$. Hence, $s_{\gop}(\goq)=a/f \in A_{\gop}$. \\
Then, $\forall s_{\gop}\in \bcO_{\gop}, \exists x\in A_{\gop}, V_{\gop}\in \tau: \gop\in V_{\gop}$, such that $s_p=[(V_p,\underline{x})]$, i.e. the germ represented by $(V_p,\underline{x})$, where by $\underline{x}$ we mean the constant section of $\bcO$ on $V_{\gop}$ that maps elements of $V_{\gop}$ to $x$.\\
Then, we can define $\Omega:\bcO_{\gop}\rightarrow A_{\gop}$, such that $s_{\gop}\mapsto s(\gop)$, as per the above settings. Then one can readily show that $\Omega$ an isomorphism.\\
\tcb{finish the proof, use the same argument to show that the sheafifications produces a sheaf!}
\item Define $\psi:A_{f}\rightarrow \bcO(D(f))$, such that $\frac{a}{f^n}\mapsto s:s(\gop)=\frac{a}{f^n},\forall \gop\in \bcO(D(f))$.\tcb{finish the proof, show that it is an isomorphism!}
\item \ref{c} is a special case of \ref{b}, for $f=1$.

Now one might would like to construct a category, whose object are spectrum of some ring, or maybe a generalization of the spectrums, and then show the association of spectrum to rings as a functor from the category of rings to the established category.
\end{enumerate}
\end{proof}

Examples!!!!!!!!!!

\begin{definition}
We defined the ringed space to be a pair $((X,\tau),\bcO_X)$, where $(X,\tau)$ is a topological space, and $\bcO_X$ a sheaf of rings on $(X,\tau)$. And we define the morphisms of ringed space to be the pair $(f,f^{\#})$, where $f:X\rightarrow Y$ is a continuous function, and $f^{\#}:\bcO_Y\rightarrow f_{\ast}\bcO_X$ a map of sheaf of rings on $Y$.\\
\end{definition}
\begin{lemma}
The ringed spaces morphism $(f,f^{\#}):((X,\tau_X),\bcO_X)\rightarrow ((Y,\tau_Y),\bcO_Y)$ between ringed spaces, introduce a ring homomorphism $f_{\gop}^{\#}:\bcO_{Y,f(\gop)}\rightarrow \bcO_{X,\gop}, \forall \gop \in X$.
\end{lemma}
\begin{proof}\label{StalkMor}
We find that, using \ref{InducedMor}, there is a ring homomorphism $(f^{\#})_{f(\gop)}:\bcO_{Y,f(\gop)}\rightarrow (f_{\ast}\bcO_X)_{f(\gop)}$ . We notice that $(f_{\ast}\bcO_X)_{f(\gop)}\subseteq \bcO_{X,\gop}$, that $\forall (f^{-1}(V),s)\in (f_{\ast}\bcO_X)_{f(\gop)}$, $s\in \bcO_{X}(f^{-1}(V)),f^{-1}(V)\in \tau_X$, that $f$ is continuous. $f(\gop)\in V\Rightarrow \gop\in f^{-1}(V)$. Hence, $(f^{-1}(V),s)\in (\bcO_X)_{\gop}$, and $\exists i:(f_{\ast}\bcO_X)_{f(\gop)}\rightarrow(\bcO_X)_{\gop}$ a ring homomorphism, and the required ring homomorphism is $f_{\gop}^{\#}=i\circ (f^{\#})_{f(\gop)}$.
\end{proof}
\begin{definition}
We say that the ringed space $((X,\tau),\bcO_X)$ is a locally ringed space if $\forall \gop \in X, \bcO_{X,\gop}$ is a local ring.\\
We call a ringed space morphism $(f,f^{\#}):((X,\tau_X),\bcO_X)\rightarrow ((Y,\tau_Y),\bcO_Y)$ between locally ringed spaces a morphism of locally ringed spaces iff the induced morphism $f_{\gop}^{\#}:\bcO_{Y,f(\gop)}\rightarrow \bcO_{X,\gop}, \forall \gop \in X$ is a local homomorphism of local rings.
\end{definition}
Example of morphism of ringed spaces between locally ringed spaces, which is not a morphism of locally ringed spaces, \tcb{construct it on the stalks level, the below proposition suggests that we should not be looking for such examples in spectrums}.

in addition to the naturality of defining the morphism of ringed spaces, of The second of the below proposition illustrate why it should be define using the direct image.
\begin{remark}
Let $A$ be a ring, then using \ref{a} one shows that $((\Spec A, \tau_A),\bcO_{\Spec A})$ is a locally ringed space.
\end{remark}
\begin{proposition}
let $\varphi:A\rightarrow B$ a homomorphism of rings, then it induces a morphism of locally ringed spaces:\\
$(f,f^{\#}):((\Spec B,\tau_B),\bcO_{\Spec B})\rightarrow ((\Spec A,\tau_A),\bcO_{\Spec A})$
Furthermore, any such morphism of locally ringed spaces is induced from a rig homomorphism $\varphi:A\rightarrow B$
\end{proposition}
\begin{proof}
Define $f:\Spec B \rightarrow \Spec A\ :\ f(\goq)=\varphi^{-1}(\goq):\goq\in \Spec B$. It is well-defined that the $\varphi^{-1}(\goq)\in \Spec A :\forall\goq\in \Spec B$. Also, we notice that $f$ is continuous that:
$\forall U\in \tau_A, U=D(l)$, for $l\in A$, then:\\
$f^{-1}(U)=\{\goq\in \Spec B: f(\goq)\in D(l) \}=
\{\goq\in \Spec B: \varphi^{-1}(\goq)\in D(l) \}=\{\goq\in \Spec B: l\notin \varphi^{-1}(\goq) \}=
\{\goq\in \Spec B: \varphi(l)\notin (\goq) \}=\{\goq\in \Spec B: (\goq)\in D(\varphi(l)) \}=D(\varphi(l)\in \tau_B$.
Since $f:\Spec B \rightarrow \Spec A$ is continuous, then the direct image define a morphism of sheaves $f^{\#}:\bcO_{\Spec A}\rightarrow f_{\ast}\bcO_{\Spec B}$, as per \ref{MSh}.\\
Also \ref{MSh} and \ref{StalkMor} shows the existence of the induced ring homomorphisms $f_{\goq}^{\#}:\bcO_{\Spec A,f(\goq)}\rightarrow \bcO_{\Spec B,\goq}, \forall \goq \in \Spec B$, such that $f_{\goq}^{\#}([(U,s|_U)])=[(f^{-1}(U),s\circ f|_{f^{-1}(U)})]\in \bcO_{\Spec B,\goq}, \forall [(U,s|_U)]\in  \bcO_{\Spec A,f(\goq)}$.\\
$\forall [(U,s|_U)]\in  \bcO_{\Spec A,f(\goq)}$, choosing $U$ small enough (with respect to the inclusion) $s|_U$ is a constant function takes values in $A_{f(\goq)}$. 

\tcb{Then, for $U$ small enough $s\circ f|_{f^{-1}(U)}$ takes the same values }\\

\tcb{finish typing part 1}\\

\tcb{finish typing part 2}
\end{proof}
\begin{remark}
What the previous proposition essentially shows is that constructing specturms of rings is a full functor from the category of rings to the category of locally ringed spaces.
\end{remark}
\begin{counterexample}
The requirement of having the induced homomorphism of morphism of locally ringed spaces to be local homomorphism is crucial in the above proposition. Otherwise, it wont be correct, as in the below example:

\end{counterexample}
\begin{definition}[Affine Scheme]\ \\
We define the affine scheme to be a locally ringed space which is isomorphic (in the category of locally ringed spaces) to a spectrum of some ring.\\
We define the affine scheme to be a locally ringed space $((X,\tau_X),\bcO_X)$ such that $\forall \gop \in X\exists U\in \tau_X:\gop\in U$ and $((U,\tau_X|_U),\bcO_X|_U)$ is an affine scheme. We call $(X,\tau_X)$ the underlying topological space of the affine scheme, and we call $\bcO_X$ the structure sheaf of the scheme. We define the morphism of schemes to be a morphism of locally ringed spaces.
\end{definition}
\begin{example}[Spectrum of rings]\ \\
\begin{itemize}
\item Let $\KK$ be a filed then $\Spec \KK=\{0\}, \tau_{\KK}=\{\emptyset,\{0\}\}$, and the structure sheaf is defined by $\bcO_{\KK}(\emptyset)=\{0\}, \bcO_{\KK}(\{0\})=\KK$.
\item Let $A$ be the polynomial ring $\KK[x]$ over some filed $\KK$. We notice that $A$ is a principal ideal domain, then each non-zero prime ideal of $A$ is a maximal ideal, i.e. $\{\gop\}$ is closed in $(\Spec A, \tau_{\Spec A}), \forall \gop \in \Spec A:\gop\neq \mathfrak{0}$.\\
We already have some information about the structure sheaf of $((\Spec A,\tau_{\Spec A}), \bcO_{\Spec A})$, and know that $\bcO_{\Spec A,\gop}=A_{\gop}=\KK[x]/{\gop}$ for every point $\gop\in \Spec A$, and we know that $\Gamma(\Spec A,\bcO_{\Spec A})=A=\KK[X]$. Therefore, in consistency with the treatment of varieties, we will call $\Spec A$ the affine line over $\KK$ and denote it by $\AF^1_{\KK}$.\\
Moreover, if $\KK$ is algebraical closed field, then the none-zero maximal ideals are all of the form $(x-k)$ for every $k\in \KK$, then there is a bijection from $\Spec A\setminus\{\mathfrak{0}\}$ to the affine space $\AF^1_{\KK}$. There is also a corresponding between all closed subsets of $(\Spec A, \tau_{\Spec A})$ and Zariski-closed subsets of $\AF^1_{\KK}$. \tcb{write the proof}\\
On the other hand, we notice that $\{\mathfrak{0}\}\subseteq \Spec A$ is not closed and that $\overline{\{\mathfrak{0}\}}=\Spec A$.
\item Let $\KK$ be an algebraically closed field, and $A=\KK[x_1,x_2,...,x_n]$, then, based on the previous argument, we see that there is a one-to-one correspondence between points of $\Spec A$ that are maximal ideals in $A$, i.e. of the form $\gom=(x_1-a_1,x_2-a_2,...,x_n-a_n)$, and points of affine space $\AF^n_{\KK}$. The main difference with the previous example is that there is non zero prime ideal in $A$ which is not maximal, i.e. there are non-zero points $\gop$, such that $\{\gop\}$ is not closed in $(\Spec A, \tau_{\Spec A})$. For example, for $n=2$, $\gop=(x_2^2-x_1^3-x_1^2)\in \Spec A$, but it is not a closed point, in fact for any pair $(a,b)\in \AF^2_{\KK}$ such that $b^2-a^3-a^2=0$, we have the maximal ideal $\gom=(x_1-a,x_2-b)\in \Spec A$ such that $\gop\subset \gom$. And we find that $\overline{\gop}$ consists of $\gop$ and points of $\Spec A$ that correspond to points of the irreducible Zariski-closed set $\VV(y^2-x^3-x^2)\subset \AF^2_{\KK}$.
\begin{figure}
\begin{center}
\includegraphics[scale=0.5]{Figures/y2-x3-x2.jpg}
\end{center}
\caption{$\VV(y^2-x^3-x^2)$}
\end{figure}
\tcb{finish the graph, and its}.
\end{itemize}
\end{example}
\begin{definition}
Let $((X,\tau_X),\bcO_X)$ be a scheme, and let $\gop\in X$ such that $\overline{\{\gop\}}=Y\subseteq X$, then we say that $\gop$ is a generic point of $Y$.
\end{definition}
In case of the above examples we see that generic point does not correspond to a an actual point of the defined affine space, but rather to an irreducible Zariski-closed subset of that space.
\begin{definition}
For an algebraically closed field $\KK$, we denote $\Spec \KK[x_1,...,x_n]$ by $\AF^n_{\KK}$, and we call it the affine space of rank $n$.
\end{definition}
\begin{proposition}[Gluing of Schemes]\ \\
Let $((X_1,\tau_{X_1}),\bcO_{X_1}), ((X_2,\tau_{X_2}),\bcO_{X_2})$ be schemes such that $\exists U_1\in \tau_{X_1},U_2\in \tau_{X_2}$ and $\exists (\varphi,\varphi^{\#}):((U_1,\tau_{X_1}|_{U_1}),\bcO_{X_1}|_{U_1})\rightarrow ((U_2,\tau_{X_2}|_{U_2}),\bcO_{X_2}|_{U_2})$ an isomorphism of locally ringed spaces. Then, there there is a scheme $((X,\tau_X),\bcO_X)$ which is the glueing Of the other two schemes along $U_1$ and $U_2$, I.e. it is the colimit of the following diagram, in the category of locally ringed spaces.\\
$((X_1,\tau_{X_1}),\bcO_{X_1})\stackrel{(i_1,i_1^{\#})}{\longleftarrow} ((U_1,\tau_{X_1}|_{U_1}),\bcO_{X_1}|_{U_1})\stackrel{(\varphi,\varphi^{\#})}{\lra} ((U_2,\tau_{X_2}|_{U_2}),\bcO_{X_2}|_{U_2})\stackrel{(i_2,i_2^{\#})}{\lra}((X_2,\tau_{X_2}),\bcO_{X_2})$\\
Where $i_1,i_2$ are the inclusion continuous maps
\end{proposition}
\begin{proof}
The category $\mathfrak{Top}$ is cocomplete, let $(X,\tau_X)$ be the colimit of the following diagram of continuous maps:\\
$(X_1,\tau_{X_1})\stackrel{i_1}{\longleftarrow} (U_1,\tau_{X_1}|_{U_1})\stackrel{\varphi}{\lra} (U_2,\tau_{X_2}|_{U_2})\stackrel{i_2}{\lra}(X_2,\tau_{X_2})$\\
Then, there is the colimit continuous maps $\tilde{i_1}:(X_1,\tau_{X_1})\rightarrow (X,\tau_X)$, $\tilde{i_2}:(X_2,\tau_{X_2})\rightarrow (X,\tau_X)$.
Then, $\forall V\in \tau_X$ we define $\bcO_X(V)=\{(s_1,s_2)\in \bcO_{X_1}(\tilde{i_1}^{-1}V)\times\bcO_{X_2}(\tilde{i_2}^{-1}V):
\}$.
Since $\bcO(\tau_{X})$ is complete, then $\mathfrak{Rng}^{\bcO(\tau_{X})}$ is complete, and the following diagram has a limit.
\[(\tilde{i}_1)_{\ast}\bcO_{X_1}\stackrel{\tilde{i}_1^{\#} i_1^{\#}}{\lra}(\tilde{i}_1)_{\ast}(i_1)_{\ast}\bcO_{U_1}
=\varphi_{\ast}(\tilde{i}_2)_{\ast}(i_2)_{\ast}\bcO_{U_2} \stackrel{\varphi^{\#}\tilde{i}_2^{\#} i_2^{\#}}{\lra}
(\tilde{i}_2)_{\ast}(i_2)_{\ast}\bcO_{U_2} \stackrel{\tilde{i}_2^{\#} i_2^{\#}}{\lra}(i_2)_{\ast}\bcO_{X_2}\]
Denote the limit of the previous diagram by $\bcO_X$, then $\bcO_X$ is a presheaf on $(X,\tau_X)$, actually it is a sheaf as we will see later on.

One can construct the previous colimit and limit as follows:\\
$X={\displaystyle\bigsqcup_{i=1}^2X_1} \Big/ {\sim}$ such that $x\sim y$ iff $x=y, x=\varphi(y), y=\varphi(x)$, and the topology $\tau_X$ is defined to be the collection of subsets of $X$ such that both preimages through $\tilde{i}_1$ and $\tilde{i}_2$ are opend in $\tau{X_1}$ and $\tau{X_2}$, respectively.\\
$\forall U\in \tau_X$, we define $\bcO_X(U)=\{(s_1,s_2)\in \bcO_{X_1}\times \bcO_{X_2}:\varphi^{\#}(s_2|_{U_2\bigcap \tilde{i}_2^{-1}(U)})=s_1|_{U_1\bigcap \tilde{i}_1^{-1}(U)}\}$

Then, one can readily check that $((X,\tau_X),\bcO_X)$ is the a scheme and that it is colimit of the given diagram in the category of locally ringed spaces.
\tcb{finilise the proof!!!!}
\end{proof}
\tcb{Is the condition on $\varphi,\varphi^{\#}$ above too strong, or is it most efficient one? Would be enough to be injective on the topological level?}
\begin{example}[A scheme which not an affine scheme]
The gluing of $X_1=X_2=\AF^{1}_{\KK}$ over $U_1=U_2=\AF^{1}_{\KK}\setminus\{p\}$.
\end{example}
From now on, let $S$ be a graded ring, and let $S_+$ denote the ideal $\oplus_{d>0}S_d$.
\begin{definition}
let $S$ be a graded ring, we define $\Proj S$ to be the set of homogeneous prime ideals of $S$ that does not contain all of $S_+$, and for any homogeneous ideal $a\subseteq S$ we define $\VV(a):=\{\gop\in \Proj s:a\subseteq \gop\}$.
\end{definition}
\begin{remark}
Lemma \ref{HD} shows why we require homogeneous prime ideals of $S$ not to contain all of $S_+$.
\end{remark}
\begin{lemma}
The set $\tau:=\{\Proj S\setminus\VV(a): a\subseteq S \text{ is a homogeneous ideal} \}$ defines a topology on $\Proj S$.
\end{lemma}
\begin{proof}
Analogue of \ref{SpecTop}.
\end{proof}
\begin{definition}
For every $U\in \tau_{\Proj S}$, define $\bcO'(U)=\displaystyle\bigcap_{\gop\in U}S_{(\gop)}$. Where $S_{(\gop)}$ is the ring of degree zero element of the localised ring a round $\gop$. Then, for $V\subseteq U\in \tau$, we have $\bcO'(U)\subseteq \bcO'(V)$, and we define $\rho_{UV}:\bcO'(U)\rightarrow \bcO'(V)$ to be the canonical inclusion.
\end{definition}

\tcb{Why to choose to work only with degree zero element, why do not we take it to be whole of $S_{\gop}$?}

\begin{lemma}
The above defined $\bcO'$ is a presheaf of rings on $(\Proj S,\tau)$, and its stalks are $\bcO'_{\gop}\cong S_{(\gop)},\forall \gop\in \Proj S$.
\end{lemma}
\begin{proof}
\tcb{Write it}.
\end{proof}
\begin{question}
Show why $\bcO'$ is not a sheaf itself! give an example.
\end{question}

Then, by Theorem \ref{AdjShf}, there is a sheaf $\bcO'^+$ of rings of functions on $(\Proj S,\tau_{\Proj S})$, and its stalks are $\bcO'^+_{\gop}\cong S_{(\gop)}$. So, what is written in \cite[P 76]{Har77} is nothing but the result the this sheafification.\\
From now on, we will denote $\bcO:=\bcO'^+$
\begin{definition}
Let $S$ be a graded ring, then we define $((\Proj S,\tau_{\Proj S}),\bcO_{\Proj S})$,  where $\bcO$ as in the above settings.
\end{definition}
\begin{lemma}
Let $S$ be a graded ring, then for $U\in \tau_{\Proj S},\bcO_{\Proj S}(U)$ is the ring of functions $s:U\rightarrow \displaystyle\bigsqcup_{\gop\in U}S_{(\gop)}$ such that $s(\gop)\in S_{(\gop)}$, and $\forall \gop\in U,\exists V\in \tau_{\Proj S}, \gop\in V\subseteq U$ such that $\exists a,f\in S_d,$ for some $d:\forall \goq\in V, f\notin \goq$ and $s(q)=a/f\in S_{(\goq)}$. And the restriction function are the canonical restrictions on set of functions.
\end{lemma}
\begin{proof}
It is just the description of sheafification.
\end{proof}
\begin{remark}
The graded ring $S$ could also be treated as a ring, and one can work with $((\Spec A, \tau_{\Spec S}),\bcO_{\Spec A})$
\end{remark}
\begin{definition}
For each $d\in \mathbb{Z}_{>0}\forall f\in S_d\subset S_+$, let $D_+(f)$ denotes the open complement of $\VV((f))$ in $(\Proj S,\tau_{\Proj S})$, i.e. $D_+(f)=\{\gop\in \Proj S:f\notin \gop\}$.
\end{definition}
\begin{lemma}\label{HD}
For each $d\in \mathbb{Z}_{>0}\forall f\in S_d\subset S_+, D_+(f)\in \tau_{\Proj S}$. Furthermore, $\{D_+(f):f\in S_d, d\in \mathbb{Z}_{>0}\}$ is an open cover for $(\Proj S,\tau_{\Proj S})$.
\end{lemma}
\begin{proposition}
Let $S$ be a graded ring, then:
\begin{enumerate}
\item $\forall \gop\in \Proj S, \bcO_{\gop}\cong S_{(\gop)}$.
\item $\forall d\in \mathbb{Z}_{>0}\forall f\in S_d\subset S_+, ((\bcO(D_+(f)),\tau_{\Proj S}|\bcO(D_+(f))),\bcO_{\Proj S}|\bcO(D_+(f)))\cong ((\Spec S_{(f)},\tau_{\Spec S_{(f)}},\bcO_{\Spec S_{(f)}}$ an isomorphism of locally ringed spaces, where $S_{(f)}$ is the subring of element of degree zero of the localized ring $S_f$.
\item $\Gamma((\Proj S,\tau_{\Proj S})\bcO_{\Proj S})$ is a scheme.
\end{enumerate}
\end{proposition}
\begin{proof} 
\end{proof}
\begin{example}
Projective $n$-space, the scheme \\$\PR^n_A=$ $((\Proj A[x_0,x_1,...,x_n], \tau_{\Proj A[x_0,x_1,...,x_n]} ),\bcO_{\Proj A[x_0,x_1,...,x_n]})$.
\end{example}

Give an example of an ideal in $S$ which is not homogeneous ideal.\\
Give example of a locally ringed space or just ringed space which is not a scheme.

\begin{question}
Give examples of advantages of schemes vs varieties.\\ Is there any scheme does not correspond to a variety rather than those with underlying rings which are not $k$-reduced finality generated algebra for some algebraically closed field $k$.
\end{question}

\begin{definition}
Let $S$ be a scheme, we define define a scheme over $S$ to be the pair $(X,\varphi)$, where $X$ is a scheme, $\varphi:X\rightarrow S$ a morphism of schemes.\\
For two schemes $(X,\varphi_X),(Y,\varphi_Y)$ over $S$, we define the morphism of schemes over $S$ (or $S$-morphism) to be a scheme morphism $\psi:X\rightarrow Y$, which make the following diagram commutative.\\
\[\xymatrix{X\ar[r]^{\varphi_X}\ar[d]_{\psi}&S\\
Y\ar[ur]_{\varphi_Y}}
\]
\end{definition}
\begin{remark}
We notice that schemes over $S$ and $S$-morphisms form a category, namely the comma category $\Sch=(\Sch \downarrow S)$, where $\Sch$ is the category of schemes.
\end{remark}
\begin{remark}
It is a generalization of vector bundles, and parametrised family of family of varieties.
\end{remark}
\begin{definition}
Let $A$ be a ring, then we define $\Sch(A)=\Sch((\Spec A, \tau_{\Spec A}),\bcO_{\Spec A})$.
\end{definition}
\begin{proposition}
For an algebraically closed field $\KK$, there is a natural full faithful functor $\mathfrak{T}:\mathfrak{var}(\KK)\rightarrow\Sch(\KK)$
\end{proposition}
\begin{proof}[idea of the proof]
For each variety $V$ we define the the set $C(V)$ of Zariski closed subsets of $V$, and topologize $C(V)$ such that its closed set are of the form $\VV(p)=\{q:a\in C(V), q\subseteq p\}$ , for every $p\in C(V)$. Then we can define $\mathfrak{T}(V)=((C(V),\tau_{C(V)}), \bcO_{C(V)})$ give rise to the required functor, where $\bcO_{C(V)}$ is the sheaf of regular functions.
\end{proof}
\begin{question}
Does it have an adjoint? Is it an equivalence? Is this functor's object function surjective? Or is there a scheme over $\KK$ which is not an image of a variety over $\KK$ as per the above proof?
\end{question}
\subsection{Properties of Schemes}
\begin{definition}[Irreducible Scheme]
A scheme $(X,\bcO_X)$ is called irreducible scheme if $(X,\tau_X)$ is an irreducible topological space.
\end{definition}
\begin{definition}[Reduced Scheme]
A scheme $(X,\bcO_X)$ is called reduced scheme if $\bcO_X(U)$ has no nilpotent element $\forall U\in \tau_X$.
\end{definition}
\begin{definition}[Integral Scheme]
A scheme $(X,\bcO_X)$ is called integral scheme if $\bcO_X(U)$ is an integral domain $\forall U\in \tau_X$.
\end{definition}
\begin{proposition}
A scheme is integral iff it is both reduced and irreducible.
\end{proposition}
\begin{definition}[Locally of Finite Type] \tcb{justify the name!!}\\
A morphism of schemes $(f,f^{\#}):(X,\bcO_X)\rightarrow (Y,\bcO_Y)$, is called locally of finite type if there exist $\{V_i=\Spec B_i|i\in I\}$ an open affine covering of $Y$, such that $\forall i\in I, f^{-1}(V_i)$ has an open affine covering $\{U_{ij}=\Spec A_{ij}|i\in J_i\}$, where $A_{ij}$ are finitely generated $B_i$-algebras. $(f,f^{\#})$ is called of finite type iff it is locally of finite type for $J_i$ finite sets, $\forall i\in I$. If $\#J_i=1,\forall i\in I$, and $A_i$ is a finitely generated $B_i$-module, then $(f,f^{\#})$ is called finite.
\end{definition}

\begin{definition}[Locally of finite presentation]
Let $f:Y\rightarrow X$ be a morphism of schemes, we say that $f$ is of finite presentation at $y\in Y$, if there are an affine neighbourhood $V$ of $y$ in $Y$, and $U$ of $f(y)$ in $X$, such that $f(V)\subseteq U$, and $f^{\#}_{U}:\bcO_X(U)\rightarrow \bcO_Y(f^{-1}(U))\rightarrow\bcO_{Y}(V)$ is an algebra of finite presentation. We say that $f$ is locally of finite presentation if it is of finite presentation at every point of $Y$.
\end{definition}
\begin{lemma}
Let $f:Y\rightarrow X$ be a morphism of affine schemes, then $f$ is locally of finite type iff $f^{\#}_X:\bcO_X(X)\rightarrow\bcO_Y(Y)$ is an algebra of finite presentation.
\end{lemma}
\begin{proof}
\tcb{EGA 4 1, 328}.
\end{proof}
\tcb{What is so special about it}


\begin{definition}[Open Subscheme]
An open subscheme of a scheme $(X,\bcO_X)$ is a scheme $(U,\bcO_U)$, for $U\in \tau_X$, and $\bcO_U\cong\bcO_{X|U}$.\\
An open immersion is a morphism of schemes $(f,f^{\#}):(X,\bcO_X)\rightarrow (Y,\bcO_Y)$, which \tcb{induce} an isomorphism of $(X,\bcO_X)$ with an open subscheme $(V,\bcO_V)$ of $(Y,\bcO_Y)$.
\end{definition}
\begin{definition}[Closed subscheme]
A closed subscheme of a scheme $(X,\bcO_X)$ is a scheme $(Y,\bcO_Y)$, together with a morphism if schemes $(i,i^{\#}):(Y,\bcO_Y)\rightarrow (X,\bcO_X)$, for $Y^c\in \tau_X$, $i$ is the inclusion map, and $i^{\#}:\bcO_X\rightarrow i_{\ast}\bcO_Y$ is surjective. \tcr{(why?)}\\
A closed immersion is a morphism of schemes $(f,f^{\#}):(X,\bcO_X)\rightarrow (Y,\bcO_Y)$, which \tcb{induce} an isomorphism of $(X,\bcO_X)$ with a closed subscheme $(V,\bcO_V)$ of $(Y,\bcO_Y)$.
\end{definition}
\begin{question}
What difference does it make having $Y$ closed in $X$? Why do not we define a subscheme in general!?  Why do we require $i^{\#}$ to be surjective? What the difference between closed subscheme and closed immersion
\end{question}
\begin{lemma}
The category of schemes $\Sch$ is a complete category, but it is not cocomplete, $\Spec \ZZ$ is its terminal object.
\end{lemma}
\begin{proof}
\tcb{type using Harshone P87}
\end{proof}
\begin{definition}[Residue Filed]
Let $(X,\bcO_X)$ be a scheme $\gop\in X$, we define the residue field of $\gop$ to be $k(\gop):=\bcO_{X,\gop}/\gom_{X,\gop}$.
\end{definition}
\tcr{is it only applicable in the case of affine schemes?}
\begin{question}
\tcb{When does the residue field equal the field on which the scheme/variety is defined?}
\end{question}
\begin{definition}[Fibers]
Let $(f,f^{\#}):(X,\bcO_X)\rightarrow (Y,\bcO_Y)$ be a morphism of schemes, $\goq\in Y$, $k(\goq)$ the residue field of $\goq$, and $(\phi,\phi^{\#}):(\Spec\ k(\goq),\bcO_{\Spec\ k(\goq)})\rightarrow (Y,\bcO_Y)$ be the morphism of schemes induced by $\phi^{\#}):\bcO_Y\hra \bcO_{Y,\goq}\twoheadrightarrow k(\goq)$, then we define the fiber of the morphism $(f,f^{\#})$ over the point $\goq$ to be the scheme:
$$
X_{\goq}:=(X,\bcO_X)\times_{(Y,\bcO_Y)}(\Spec\ k(\goq),\bcO_{\Spec\ k(\goq)})
$$
\end{definition}
\begin{terminology}
From now on, we will abuse notion, and reefer to the scheme $(X,\bcO_X)$ using its underlying topological space $X$, and we will denote the underlying topological space by $|X|$.
\end{terminology}



\begin{lemma}(Scheme-Theoretical Image)\textup{\cite[$\S$ II, Ex 3.11, P 92]{Har77}}\\
Let $(f,f^{\#}):(X,\bcO_X)\rightarrow (Y,\bcO_Y)$ be a morphism of schemes, then there exist a closed subscheme $(i,i^{\#}):(X_f,\bcO_{X_f})\nhookrightarrow (Y,\bcO_Y)$, such that $(f,f^{\#})$ factors uniquely through $(i,i^{\#})$. Furthermore, for every such closed subscheme $(j,j^{\#}):(Z_f,\bcO_Z)\nhookrightarrow (Y,\bcO_Y)$ , $(i,i^{\#})$ factors uniquely through $(j,j^{\#})$.
\end{lemma}
\begin{proof}
\noindent Let $(j,j^{\#}):(Z_f,\bcO_Z)\nhookrightarrow (Y,\bcO_Y)$  be a closed subscheme of $(Y,\bcO_Y)$, such that $\exists! (g,g^{\#}):(X,\bcO_X)\rightarrow (Z,\bcO_Z)$ for which $(f,f^{\#})=(j,j^{\#})\circ (g,g^{\#})$. \tcb{The set of such closed subschemes is not empty, that $(id_Y,id_{\bcO_Y})$ belongs to it.}\\
\noindent Denote $Y'=\overline{\Imm f}\subseteq Y$, the topological closure of the image of $f$. Let $i:Y'\rightarrow Y$ be the canonical inclusion of topological spaces. Then, it is easy to see that there is a unique continuous map $f':X\rightarrow Y'$, giving by $f'(x)=f(x)\forall x\in X$, such that $f=i\circ f'$.\\
\noindent Define $h:\Imm f\rightarrow Z$, $h(f(x))=g(x)$, since $j$ is a monomorphism, and $f=j\circ g$, it is easy to see that $h$ is a well defined continuous map, and satisfies $i|_{\Imm f}=j\circ h$, and that it is the unique such continuous map. $\Imm f$ is dense  in $Y'$, hence $h$ extends uniquely the continuous map $j_{'}:Y'\rightarrow Z$. Furthermore, $i=j\circ j_{'}$\\
\noindent \tcb{$\forall y\in Y', \exists \{y_n=f(x_n)\}_{n\in \NN}$ a sequence in $\Imm f$, such that $y=\displaystyle \lim_{n\rightarrow \infty} f(x_n)$. $\{f(x_n)\}_{n\in \NN}$ converges to $y$, hence it is Cauchy, and so is $\{g(x_n)=h(f(x_n))\}_{n\in \NN}$, and it converges in the $Z$. Then, $j_{'}(y)=\displaystyle \lim_{n\rightarrow \infty} g(x_n)$.}\\
Then we have the commutative diagram:
$$
\xymatrix{
X\ar[rr]^f	\ar@{-->}[rd]|{f'}\ar@{-->}[rddd]_{g}&		&	Y\\
			&Y'\ar@{^(->}[ur]|i\ar@{_(-->}[dd]|{j_{'}}	&\\\\
			&Z\ar@{^(->}[uuur]_j	&
}
$$
Consider the exact sequence of sheaves on $Y$:\\
$\xymatrix{0\ar[r]&\bcI_X\ar@{^(->}[r]&\bcO_Y\ar[r]^{f^{\#}}&f_{\ast}\bcO_X}$\\
We notice on the level of stalks that $\bcI_{X,\goq}\cong\bcO_{Y,\goq}$ for $\goq\nin \Imm f\subseteq\Imm i$. Hence, $( \bcO_Y/\bcI_X )_{\goq}=0$ for $\goq\nin \Imm i$.
Then define the sheaf $\bcO_{Y'}$ on $Y'$ to be $i^{-1}\ \bcO_Y/\bcI_X $. Notice that, since $(i,i^{\#})$ is a closed subscheme of $(Y,\bcO_Y)$, then $i_{\ast}\bcO_{Y'}\cong \bcO_Y/\bcI_X$, that on stalks, we have, $\forall \goq\in Y:$\\
$(i_{\ast}i^{-1}\ \bcO_Y/\bcI_X )_{\goq}=
\left\{\begin{array}{ll}
(i^{-1}\ \bcO_Y/\bcI_X )_{i^{-1}(\goq)}&\goq\in \Imm i\\
0& \goq\nin \Imm i
\end{array}
\right.=
\left\{\begin{array}{ll}
( \bcO_Y/\bcI_X )_{\goq}&\goq\in \Imm i\\
0& \goq\nin \Imm i
\end{array}
\right.=( \bcO_Y/\bcI_X )_{\goq}
$\\

\noindent Let $i^{\#}:\bcO_Y\twoheadrightarrow i_{\ast}\bcO_{Y'}\cong \bcO_Y/\bcI_X$ be the canonical injection. Since $\xymatrix{\bcI_X\ar@{^(->}[r]&\bcO_Y\ar[r]&f_{\ast}\bcO_X}$ is zero, then there is a unique morphism of sheaves $u:i_{\ast}\bcO_{Y'}\rightarrow f_{\ast}\bcO_X$, that makes the following diagram commutate:
\noindent $$
\xymatrix{
f_{\ast}\bcO_X&&\bcO_Y\ar@{->>}[ld]^{i^{\#}}\ar[ll]_{f^{\#}}\\
&i_{\ast}\bcO_{Y'}\ar@{-->}[lu]^{u}&
}
$$
\noindent We have the commutative diagram:
\noindent $$
\xymatrix{
f_{\ast}\bcO_X&&\bcO_Y\ar@{->>}[ld]^{j^{\#}}\ar[ll]_{f^{\#}}\\
&j_{\ast}\bcO_{Z}\ar[lu]^{j_{\ast}g^{\#}}&
}
$$
\noindent Since $\xymatrix{\bcI_Z\ar@{^(->}[r]&\bcO_Y\ar@{->>}[r]^{j^{\#}}&j_{\ast}\bcO_Z}$ is zero, then $\xymatrix{\bcI_Z\ar@{^(->}[r]&\bcO_Y\ar[r]^{f^{\#}}&f_{\ast}\bcO_X}$, hence there is a unique morphism of sheaves $v:\bcI_Z\hra \bcI_X$ that makes the following diagram commute:
$$
\xymatrix{\bcI_Z\ar@{^(-->}[rr]^v\ar@{^(->}[dr]&&\bcI_X\ar@{_(->}[dl]\\
&\bcO_Y&
}
$$
\noindent $\xymatrix{\bcI_X\ar@{^(->}[r]&\bcO_Y\ar@{->>}[r]^{i^{\#}}&i_{\ast}\bcO_{Y'}}$ is zero, then $\xymatrix{\bcI_Z\ar@{^(->}[r]&\bcO_Y\ar@{->>}[r]^{i^{\#}}&i_{\ast}\bcO_{Y'}}$ is zero. Since $(j,j^{\#})$ is a closed embedding, then $j_{\ast}\bcO_Z\cong \bcO_Y/\bcI_Z$, hence there is a unique morphism of sheaves $t:j_{\ast}\bcO_Z\twoheadrightarrow i_{\ast}\bcO_{Y'}$ that makes the following diagram commute:
\noindent $$
\xymatrix{
&\bcO_Y\ar@{->>}[ld]_{i^{\#}}\ar[ddl]^{j^{\#}}\\
i_{\ast}\bcO_{Y'}&\\
j_{\ast}\bcO_{Z}\ar@{-->>}[u]^{t}&
}
$$
\noindent Then, we have the commutative diagrams:
\noindent $$
\xymatrix{
\bcI_Z\ar@{^(->}[rd]\ar@{^(-->}[dd]_v&&i_{\ast}\bcO_{Y'}\ar[rd]^u&\\
&\bcO_Y\ar@{->>}[ru]^{i^{\#}}\ar@{->>}[rd]_{j^{\#}}\ar[rr]&&f_{\ast}\bcO_X\\
\bcI_X\ar@{^(->}[ru]&&j_{\ast}\bcO_{Z}\ar[ru]_{j_{\ast}g^{\#}}\ar@{-->>}[uu]&
}
$$
\noindent $$
\xymatrix{
f_{\ast}\bcO_X&&\bcO_Y\ar@{->>}[ld]_{i^{\#}}\ar[dddl]^{j^{\#}}\ar[ll]_{f^{\#}}\\
&i_{\ast}\bcO_{Y'}\ar@{-->}[lu]_u&\\\\
&j_{\ast}\bcO_{Z}\ar@{-->>}[uu]_{t}\ar[luuu]^{j_{\ast}g^{\#}}&
}
$$
\tcb{
\noindent Show that $(Y',\bcO_{Y'})$ is a scheme, and that $(i,i^{\#})$ is a closed embedding.\\
$u$ and $t$ are not the needed morphisms. Show the existence and uniqueness of the needed morphisms.\\
Type the conclusion\\
Examples of ringed spaces which are not schemes\\
Show that $f_{\ast}$ and $f^{-1}$ are functors.
}
\end{proof}
\begin{definition}[Geometric Point]
\noindent Let $X$ be a schemes over a field $\kk$, we say say that $x\in X$ is a geometric point of $X$, if its residue field $\kk(x)$ is isomorphic to the algebraic closure of $\kk$.
\end{definition}
\noindent We think of geometrical points as the intuitive point of the classical variety the scheme represent. \tcr{Does it have to be closed?}
\begin{definition}[Generic Point]
\noindent Let $X$ be a schemes over a field $\kk$, we say say that $x\in X$ is a geometric point of $X$, if its residue field $\{x\}$ is not closed in Zariski topology given on $X$.
\end{definition}
\noindent We think of the generic points as the variety given by their closure in $X$.
\begin{definition}[Regular Scheme]
Let $X$ be a scheme, we say that $X$ is regular at $x\in X$ if the local ring $\bcO_{X,x}$ is a regular local ring. We say that $X$ is regular if it is regular at every point $x\in X$.
\end{definition}
\tcb{Mention What it represents}.

\begin{definition}[Fibers]
Let $f:Y\rightarrow X$ be a morphism of schemes, $x\in X$, we define:
\begin{itemize}
\item The fiber of $f$ at $x$, to be the set $f^{-1}(\{x\})$, where $f$ is understood as a map on the underlying topological spaces, denoted by $f^{-1}(x)$.
\item The scheme-theoretical fiber of $f$ at $x$, to be the fiber product $Y\times_X \Spec \kk(x)$, where $\kk(x)$ is the residue field at $x$.
\end{itemize}
\end{definition}
\begin{lemma}
Let $f:Y\rightarrow X$ be a morphism of schemes, $x\in X$, then the previous definitions of fibers coincide on the level of sets $f^{-1}(x)=|Y\times_X \Spec \kk(x)|$.
\end{lemma}

\begin{definition}[Smooth Morphism]
Let $f:Y\rightarrow X$ be a morphism of schemes over a field $\kk$, we say that $f$ is smooth if:
\begin{itemize}
\item $f$ is locally of finite type.
\item $f$ is flat.
\item For any geometric point $x\tcr{\hookrightarrow} X$, the scheme-theoretical fiber of $f$ at $x$, $Y_x$ is a regular scheme.
\end{itemize}
\end{definition}
\noindent \tcr{Is it global concept? Can it be given locally at points that are not geometric?}\\
\noindent \tcr{Does the notion of smoothness make sense for arithmetic schemes?}
\black
\begin{lemma}[Reduced Induced Closed Subscheme Structure]\label{ReducedInduced}
Let $X$ be a scheme, $Z\subseteq X$ a closed subset. Then there is a unique reduced closed sub-scheme of $X$ with underlying topological space coincide with $Z$.
\end{lemma}
\begin{proof}
\cite[\href{http://stacks.math.columbia.edu/tag/01J3}{Tag 0123}]{stacks-project}
\end{proof}
\noindent The closed sub-scheme in \ref{ReducedInduced} is called the reduced induced closed sub-scheme of $Z$ in $X$ and denoted by $Z_{red}$
\begin{lemma}
Let $X$ be a scheme, $Z\subseteq X$ a closed subset. $Z_{red}$ is the smallest closed sub-scheme in $X$ with underlying space $Z$.
\end{lemma}
\begin{lemma}\label{SchCoproduct}
The category of $\Sch/S$ has a \tcb{finite} co-product.
\end{lemma}
\begin{proof}
Let $X,Y$ be schemes, and consider the ringed space $X\coprod Y:=(|X|\bigsqcup|Y|,i_{\ast}\bcO_X\times j_{\ast}\bcO_Y)$, where $i:|X|\hookrightarrow |X|\bigsqcup |Y|$ and $j:|Y|\hookrightarrow |X|\bigsqcup |Y|$ are the canonical embeddings. \tcb{We can readily see that $X\coprod Y$ is a \tcr{scheme} over $S$, moreover it is the co-product of $X$ and $Y$.}
\end{proof}
\begin{lemma}\label{SchDistributive}
In the category $\Sch/S$, the product is distributive over \tcr{finite} co-product.
\end{lemma}
\begin{proof}
\tcb{The proof is based on the fact that tensor product of rings is distributive over the direct product of rings.}
\end{proof}
\begin{lemma}\label{SchOpIntersection}
Let $X$ be a scheme, $U_1,U_2$ a family of open subschemes of $X$. Then, $U_1\times_X U_2$ coincide with the open subscheme with the underlying topological space $|U_1| \bigcap |U_2|$.
\end{lemma}

\begin{lemma}\label{SchOpUnion}
Let $X$ be a scheme, $\{j_i:U_i\hookrightarrow X\}_{i\in I}$ a family of open subschemes of $X$. Then, the open subscheme $\displaystyle\bigcup_{i\in I}U_i$ coincide with the colimit of the embedding functor from the $\goi:\mathbf{OpSch_I}/X\rightarrow \mathbf{OpSch}/X$, where $\mathbf{OpSch}/X$ the category of open subschemes in $X$ with the morphisms being the embeddings, and $\mathbf{OpSch_I}/X$ the full subategory of $\mathbf{OpSch}/X$ with objects being open subschemes of $U_i$ for some $i\in I$.
\end{lemma}
\noindent Here the union as in gluing schemes. This colimit always exist.\\
\tcb{The above definition might need to be restricted to fiber product to avoid the need of the below lemma, in case it was not correct.}
\begin{lemma}\label{SchOpSubFiber}
Let $f:Y\rightarrow X$ a morphism of schemes, $U$ an open subscheme of $X$, then for any open subscheme $V$of $Y\times_X U$, there is a open subscheme $W$ of $U$ such that $Y\times_X W\cong V$.
\end{lemma}
\begin{lemma}\label{SchDisFberUnion}
Let $X$ be a scheme, $\{f_i:X_i\rightarrow X\}_{i\in I}$ a family of scheme morphisms. If $I$ is finite, then $\displaystyle\bigcup_{i\in I} (Y\times_X X_i)\cong Y\times_X \displaystyle\bigcup_{i\in I} X_i$.
\end{lemma}

\begin{counterexample}
Give an example of a morphism of schemes $f:Y\rightarrow X$ that is not of finite type, where $Y$ is Noetherian.
\end{counterexample}
\tcb{Joe's explanation of finite type}.
\begin{definition}[Noetherian Schemes]\label{Noetherian Schemes}
We say that a scheme $X$ is Noetherian iff it can be covered by finite number of open affine schemes $\Spec A_i$, where each $A_i$ is a Noetherian ring.
\end{definition}
\begin{lemma}
A scheme $X$ is Noetherian iff it's locally Noetherian and quasi-compact.
\end{lemma}